/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.internal;

import org.eclipse.ui.IStartup;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

import edu.pku.sei.modeler.actions.MetaModelActionProvider;
import edu.pku.sei.modeler.actions.registry.MetaModelActionRegistry;
import edu.pku.sei.modeler.explorer.MetaModelView;
import edu.pku.sei.modeler.explorer.registry.TreeViewProviderRegistry;
import edu.pku.sei.modeler.project.ProjectRegistry;
import edu.pku.sei.modeler.treeview.MetaModelContentProvider;
import edu.pku.sei.modeler.treeview.MetaModelLabelProvider;

/**
 * @author zl
 *
 */
public class MainStartUp implements IStartup {

	/* (non-Javadoc)
	 * @see org.eclipse.ui.IStartup#earlyStartup()
	 */
	public void earlyStartup() {
		System.out.println("main bundle started");
		MetaProjectFactory factory = new MetaProjectFactory();
//		context.registerService(AbstractProjectFactory.class.getName(), factory, null);
		ProjectRegistry.getDefault().addProjFactory(factory);
		MetaModelActionRegistry.getDefault().addActionFactory(new MetaModelActionProvider());
		TreeViewProviderRegistry.getDefault().addTreeViewProvider(new MetaModelContentProvider(), new MetaModelLabelProvider());
		IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if(win!= null) {
			IViewPart view = win.getActivePage().findView("edu.pku.sei.modeler.explorer.MetaModelView");
			if(view instanceof MetaModelView) {
				((MetaModelView)view).updateInput();
			}
		}
	}

}
